
/***************************************************************************************
****************************************************************************************
* FILE		: key.h
* Description	: 
*			  
* Copyright (c) 2020 by Simlife. All Rights Reserved.
* 
* History:
* Version		Name			Date				Description
   0.1			Alen			2020/05/07			Initial Version
   
****************************************************************************************
****************************************************************************************/

#ifndef _KEY_H_
#define _KEY_H_

#define key1Port _pa
#define key1PortAndPin _pa1
#define key1Pin PIN_1
#define key1PinReverse PIN_1_REVERSE
#define key1PortTypeControl _pac
#define key1PortPullupControl _papu
#define key1PortWakeUpControl _pawu

#define key2Port _pa
#define key2PortAndPin _pa2
#define key2Pin PIN_2
#define key2PinReverse PIN_2_REVERSE
#define key2PortTypeControl _pac
#define key2PortPullupControl _papu
#define key2PortWakeUpControl _pawu

#define releaseTime 6
#define debounceTime 6
#define shortPressTime 6
#define longPressTime 120

#define shortFlag 0x80
#define longFlag 0x40
#define waiteReleaseFlag 0x20
#define releaseFlag 0x10

typedef enum
{
	IDLE = 0,
	DEBOUNCE,
	SHORT_PRESS,
	LONG_PRESS,
	WAIT_RELEASE,
} enumKeyStatus;

typedef struct _structKeyCount
{
	unsigned char debounce;
	unsigned char release;
} structKeyCount;

typedef enum _keyValue
{
	NULL_KEY = ((U8)0x00),
	ON_OFF_KEY = ((U8)0x01),
	MODE_KEY = ((U8)0x02)
} keyValue;

extern void initKeyControlPin(void);
extern U8 keyScan(void);
extern void keyProcess(U8 keyValue);

#endif /*_KEY_H_*/
